<?php 
	include './init.php';
	$model=new Model('order_list');
	$a=$_GET['a'];
	switch ($a) 
	{
		case 'pay':
			$id=$_GET['id'];
			$sql="select `is_pay` from `order_list` where id=$id";
			$is_pay=$model->find($sql)[0]['is_pay'];
			$is_pay=$is_pay?0:1;

			$data['is_pay']=$is_pay;
			$where['id']=$id;

			$res=$model->update($data,$where);
			if ($res) 
			{
				success('付款成功',$_SERVER['HTTP_REFERER'],1);
				return false;
			}
			break;

			case 'shou':
				$id=$_GET['id'];
				$data['is_delivery']=2;
				$where['id']=$id;
				$res=$model->update($data,$where);
				if ($res) 
				{
					header('location:'.URL.'/personal_order.php');
					return false;
				}
				break;

				case 'comment':
					$id=$_POST['id'];
					$sql="select `is_delivery` from `order_list` where id=$id";
					$result=$model->find($sql)[0]['is_delivery'];
					if ($result!=2) 
					{
						error('还木有签收，等一下下再给好评吧！');
						return false;
					}
					else{
							$data['order_id']=$_POST['id'];
							$data['uid']=$_SESSION['user']['id'];
							$data['text']=empty($_POST['text'])?'系统默认好评！':$_POST['text'];
							$data['comtime']=time();
							$model1=new Model('comments');

							$res=$model1->insert($data);
							if ($res) 
							{
								success('评论发表成功，等待审核！',URL.'/comments.php?id='.$_POST['id'],1);
								return false;
							}
						}
					break;
		
	}
?>